package com.af.security.mgt.account.register.token.event;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author : zhenyun.su
 * @comment : 发布事件，
 * 默认情况下同步执行的； 若要异步则添加 @Async 注解， 同时需要配置@EnableAsync
 * @since : 2020-7-20
 */


@Component
public class UserRegisterTokenPublisher implements ApplicationContextAware {
    private ApplicationContext ctx;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.ctx = applicationContext;
    }
    @Async
    public void publishTokenEven(UserRegisterTokenEvent event){
        this.ctx.publishEvent(event);
    }
}
